$(function(){
    var mySwiper = new Swiper('.swiper-container',{
        pagination: {
            el: '.swiper-pagination',
        },
    })

    var SubMit1 = document.querySelector('.IpIntegralRule');
    var modle1 = document.querySelector('.Model1');
    SubMit1.index = true;
    SubMit1.addEventListener('click', function() {
        if (SubMit1.index) {
            modle1.className = 'Model Model1 Model-active'
            SubMit1.index = !SubMit1.index
        } else {
            return false
        }
    })
    modle1.addEventListener('click', function() {
        if (!SubMit1.index) {
            modle1.className = 'Model Model1'
            SubMit1.index = !SubMit1.index
            // window.location.reload();
        } else {
            return false
        }
    })

    var SubMit2 = document.querySelector('.SubMit2');
    var modle2 = document.querySelector('.Model2');
    SubMit2.index = true;
    SubMit2.addEventListener('click', function() {
        if (SubMit2.index) {
            modle2.className = 'Model Model2 Model-active'
            SubMit2.index = !SubMit2.index
        } else {
            return false
        }
    })
    modle2.addEventListener('click', function() {
        if (!SubMit2.index) {
            modle2.className = 'Model Model2'
            SubMit2.index = !SubMit2.index
            // window.location.reload();
        } else {
            return false
        }
    })
    document.querySelector('.model-button').addEventListener('click', function() {
        if (!SubMit2.index) {
            modle2.className = 'Model Model2'
            SubMit2.index = !SubMit2.index
            // window.location.reload();
        } else {
            return false
        }
    })

    $('.IndexUser').click(function(e){
        location.href=getRootPath()+'/GasHome/Mine/Index?park_id='+$('#park_id').val();
    });

    getGasMsg();
    setInterval(function(){getGasMsg();},30000);
})

function getGasMsg(){
    $.ajax({
        type: "post",
        url: "Api/GasIndex/getGasMsg",
        data:{
            admin_id:$('#admin_id').val(),
            park_id:$('#park_id').val()
        },
        async: true,
        dataType: 'json',
        success: function(data) {
            if(data.status){
                var t=JSON.parse(data.v);
                // alert(t.content);
                $('.gas-msg').html(t.content);
                $('.SubMit2').click();
            }
            else{
                // errorAlert(data.msg);
            }
        }
    });
}

